package com.okilo.online.app.apt

import android.widget.LinearLayout
import androidx.recyclerview.widget.RecyclerView
import com.okilo.online.app.R
import com.okilo.online.app.tools.apt.OkiloRecyclerViewAdapter
import com.okilo.online.app.tools.apt.OkiloViewHolderHelper
import org.json.JSONObject

/**
 * OkiloLoan
 * @Author wwdeng
 * @CreateTime: 2024/11/19 13:54
 * @Annotation：手机号校验 - 类型
 */
class OkiloVerifyMobileTypeApt(recyclerView: RecyclerView?) :
    OkiloRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.okilo_act_verify_mobile_type_item) {
    override fun setItemChildListener(helper: OkiloViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.okiloVerifyMobileTypeListItemLayout)//选择
    }

    override fun fillData(helper: OkiloViewHolderHelper, position: Int, model: JSONObject) {
        val okiloVerifyMobileTypeListItemLayout = helper.getView<LinearLayout>(R.id.okiloVerifyMobileTypeListItemLayout)
        val okiloVerifyMobileTypeImage = helper.getImageView(R.id.okiloVerifyMobileTypeImage)
        val okiloVerifyMobileTypeText = helper.getTextView(R.id.okiloVerifyMobileTypeText)
        val okiloVerifyMobileTypeStatus = helper.getImageView(R.id.okiloVerifyMobileTypeStatus)
        okiloVerifyMobileTypeText.text = model.optString("title")

        if (model.optBoolean("isSelected", false)) {
            okiloVerifyMobileTypeListItemLayout.setBackgroundResource(R.drawable.okilo_check_mobile_type_select_bg)
            okiloVerifyMobileTypeImage.setImageResource(model.optInt("selectIcon"))
            okiloVerifyMobileTypeText.setTextColor(getColor(R.color.okilo_color_white))
            okiloVerifyMobileTypeStatus.setImageResource(R.mipmap.okilo_check_mobile_type_select)
        } else {
            okiloVerifyMobileTypeListItemLayout.setBackgroundResource(R.drawable.okilo_check_mobile_type_normal_bg)
            okiloVerifyMobileTypeImage.setImageResource(model.optInt("normalIcon"))
            okiloVerifyMobileTypeText.setTextColor(getColor(R.color.okilo_color_ff747378))
            okiloVerifyMobileTypeStatus.setImageResource(R.mipmap.okilo_check_mobile_type_normal)
        }
    }
}